package cc.vicp.djx314.starfood.web.personnel.order;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

import cc.vicp.djx314.starfood.domain.order.Order;
import cc.vicp.djx314.starfood.service.order.OrderService;

@Controller
public class GetOrderForFlowByIdController {
	public static final Logger logger = LoggerFactory.getLogger(GetOrderForFlowByIdController.class);

	@Autowired
	private OrderService orderService;

	@RequestMapping(value = "/personnel/flow/order/{orderId}", method = RequestMethod.GET)
	public ModelAndView getOrderForFlow(@PathVariable("orderId") Integer orderId) {
		Order order = orderService.getOrderForFlowById(orderId);
		ModelAndView model = new ModelAndView("jsontournamenttemplate");
		if (order == null) {
			model.addObject("success", false);
		} else {
			model.addObject("order", order);
			model.addObject("success", true);
		}
		return model;
	}
}